package org.sakai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
    
    @Bean
    public RestTemplate restTemplate() {
        // 使用 SimpleClientHttpRequestFactory 手动设置超时
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        factory.setConnectTimeout(100_000);   // 连接超时 100 秒
        factory.setReadTimeout(120_000);     // 读取超时 120 秒 —— 与 server.connection-timeout 对齐

        return new RestTemplate(factory);
    }
} 